asm
  ld sp,$E7FF
  end asm

#include "./library/smsrnd.bas"
#include "./library/smsdelay.bas"

dim eee as uinteger at $E010
dim seed as uinteger at $E012
dim ee0 as uinteger at $E014
dim ee1 as uinteger at $E016
dim ee2 as uinteger at $E018
dim ee3 as uinteger at $E01A
dim ee4 as uinteger at $E01C
dim ee5 as uinteger at $E01E
dim ex0 as uinteger at $E020
dim ey0 as uinteger at $E022
dim ej0 as uinteger at $E024
dim ej1 as uinteger at $E026
dim eex as uinteger at $E028
dim eey as uinteger at $E02A

sub msisaacputchar(txp1 as uinteger,typ1 as uinteger,tch1 as ubyte,tly1 as uinteger):
  poke $F400+($400*tly1)+(31-typ1)+(txp1*32),tch1
  end sub

sub msisaacscroll(txp1 as ubyte,typ1 as ubyte,tly1 as uinteger):
  poke $F0C0+(2*tly1),txp1
  poke $F0C1+(2*tly1),typ1
  end sub

sub msisaacputsprite(tly1 as uinteger,txp1 as ubyte,typ1 as ubyte,tch1 as ubyte,tat1 as ubyte):
  poke $F100+(tly1*4),typ1 bxor $FF
  poke $F101+(tly1*4),txp1 bxor $FF
  poke $F102+(tly1*4),tat1
  poke $F103+(tly1*4),tch1
  end sub

sub msisaacpalette(tid1 as uinteger,tvl1 as uinteger):
  poke uinteger $E800+(2*tid1),tvl1
  end sub

seed=0
seed=smsrnd(seed)

for eee=0 to 1023
  seed=smsrnd(seed)
  msisaacpalette(eee,seed)
  next

msisaacpalette($100,$F00)
msisaacpalette($200,$F70)
msisaacpalette($300,$FF0)

for ee0=0 to 31
  for ee1=0 to 31
    seed=smsrnd(seed)
    msisaacputchar(ee1,ee0,seed band $0F,1)
    next:next

for ee0=0 to 15
  for ee1=0 to 15
    msisaacputchar(ee1+14,ee0+15,ee1+(ee0*16),1)
    next:next

eex=8:eey=8:eee=0


do

  ej0=peek($F080) bxor $FF
  msisaacputchar(4,1,48+(ej0 mod 10),1)
  msisaacputchar(3,1,48+((int(ej0/10)) mod 10),1)
  msisaacputchar(2,1,48+((int(ej0/100)) mod 10),1)

  ej0=peek($F081) bxor $FF
  msisaacputchar(4,2,48+(ej0 mod 10),1)
  msisaacputchar(3,2,48+((int(ej0/10)) mod 10),1)
  msisaacputchar(2,2,48+((int(ej0/100)) mod 10),1)

  ej0=peek($F082) bxor $FF
  msisaacputchar(4,3,48+(ej0 mod 10),1)
  msisaacputchar(3,3,48+((int(ej0/10)) mod 10),1)
  msisaacputchar(2,3,48+((int(ej0/100)) mod 10),1)

  ej0=peek($F083) bxor $FF
  msisaacputchar(4,4,48+(ej0 mod 10),1)
  msisaacputchar(3,4,48+((int(ej0/10)) mod 10),1)
  msisaacputchar(2,4,48+((int(ej0/100)) mod 10),1)

  ej0=peek($F084) bxor $FF
  msisaacputchar(4,5,48+(ej0 mod 10),1)
  msisaacputchar(3,5,48+((int(ej0/10)) mod 10),1)
  msisaacputchar(2,5,48+((int(ej0/100)) mod 10),1)

  eex=eex-((ej0 band 4)/4)+((ej0 band 8)/8)
  eey=eey+((ej0 band 16)/16)-((ej0 band 32)/32)
  msisaacputchar(eex,eey,eee mod $69,1)

  eee=eee+1
  smsdelay(1000)

  loop

do:loop


